def replace3(x):
if len(x) <= 4:
return x
str = x[len(x) - 2:] + x[2: len(x) - 2] + x[0:2]
return str
Function Call | Return Value | |||
---|---|---|---|---|
replace3('hello') | → | |||
replace3('goodbye') | → | |||
replace3(' world ') | → | |||
replace3('') | → | |||
replace3('oof') | → | |||
replace3('a') | → |
Experiment with this code on Gitpod.io